home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / include / log.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.1 KB  |  131 lines

  1. #ifndef _LOG_H_
  2. #define _LOG_H_
  3. /*
  4.  *   $RCSfile: log.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:45 $      
  7.  */ 
  8. /**********************************************************************
  9. * EXODUS Database Toolkit Software
  10. * Copyright (c) 1991 Computer Sciences Department, University of
  11. *                    Wisconsin -- Madison
  12. * All Rights Reserved.
  13. *
  14. * Permission to use, copy, modify and distribute this software and its
  15. * documentation is hereby granted, provided that both the copyright
  16. * notice and this permission notice appear in all copies of the
  17. * software, derivative works or modified versions, and any portions
  18. * thereof, and that both notices appear in supporting documentation.
  19. *
  20. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  21. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  22. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  23. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  24. *
  25. * The EXODUS Project Group requests users of this software to return 
  26. * any improvements or extensions that they make to:
  27. *
  28. *   EXODUS Project Group 
  29. *     c/o David J. DeWitt and Michael J. Carey
  30. *   Computer Sciences Department
  31. *   University of Wisconsin -- Madison
  32. *   Madison, WI 53706
  33. *
  34. *     or exodus@cs.wisc.edu
  35. *
  36. * In addition, the EXODUS Project Group requests that users grant the 
  37. * Computer Sciences Department rights to redistribute these changes.
  38. **********************************************************************/
  39.  
  40. /*
  41.  *    Maximum transactions that can be logged in a checkpoint record.
  42.  *    This maximum is designed to guarantee that stack space required
  43.  *    to generate a checkpoint record is < 3K since stack space is
  44.  *    limited to around 4K.  The sanity of this value is checked in
  45.  *    checkPoint().
  46.  */
  47. #define MAXTRANSCHKPNT    50
  48.  
  49. /*
  50.  *    When a page is first dirtied, there are two ways to determine
  51.  *    the LRC of the first log record to update the page.  For
  52.  *    debugging purposes incrementing the LRC on the page is 
  53.  *    most appropriate since it guarantees that the LRC on a pages is
  54.  *    always an exact count of the number of operations performed on 
  55.  *    a page.  But, this requires additional LSN comparisons while
  56.  *    redoing records and requires patching LRC's on pages where
  57.  *     the server has a log record but the page was not shipped before
  58.  *    the transaction was aborted.
  59.  *
  60.  *    To overcome these deficiencies the second way to determine the
  61.  *    first LRC to dirty a page is to use the current end-of-log LSN.
  62.  *    The server init's the lrc in a page with this lsn before
  63.  *    shipping it to the client.  When a page is first allocated 
  64.  *    its LRC is also set to the end-of-log.
  65.  *
  66.  *    If the macro INIT_LRC_IS_LSN is defined then end-of-log LSNs 
  67.  *    are used, otherwise the LRC is simply incremented and 
  68.  *    patching is turned on.
  69.  */
  70. #define INIT_LRC_IS_LSN
  71.  
  72. /*
  73.  *    This routine generates a new lrc for a page.
  74.  */
  75. #ifdef INIT_LRC_IS_LSN
  76. #    define GENERATE_LRC(_lrc)        \
  77.             ( (_lrc)->wrapCount = OpenLog.wrapCount,          \
  78.               (_lrc)->count        = OpenLog.tailLSN,            \
  79.               (_lrc))
  80. #else
  81. #    define GENERATE_LRC(_lrc)        INCREMENT_LRC((_lrc))
  82. #endif /* INIT_LRC_IS_LSN */
  83.  
  84. /*
  85.  *    define a macro for setting the dependency lsn
  86.  */
  87. #define DEPEND_LOG(_pageHash, _forceMark, _lsn, _lrc)        \
  88.                                                     \
  89.     if ((_pageHash)->lsn.offset == 0)    {            \
  90.                                                     \
  91.         ((_pageHash)->lsn) = *(_lsn);                \
  92.         ((_pageHash)->lrc) = *(_lrc);                \
  93.     }                                                \
  94.     (_pageHash)->forceMark = _forceMark;            \
  95.     DIRTY_PAGE((_pageHash));
  96.  
  97.  
  98. /*
  99.  *    Define an error code that will signal a checkpoint
  100.  */
  101. #define LOG_DO_CHECKPOINT    1
  102. #define LOG_EOF                2
  103.  
  104.  
  105. /*
  106.  *    define some log flags
  107.  */
  108. #define LOG_RECOVERY    0x1
  109.  
  110.  
  111. /*
  112.  *    Macro to initialize the lrc on a newly allocated page
  113.  */
  114. #ifdef INIT_LRC_IS_LSN
  115. #    define INITIALIZE_LRC(_lrc)                \
  116.             ((_lrc)->wrapCount = OpenLog.wrapCount,        \
  117.              (_lrc)->count = OpenLog.tailLSN, (_lrc))    
  118. #else
  119. #    define INITIALIZE_LRC(_lrc)                \
  120.             ((_lrc)->wrapCount = 0,    (_lrc)->count = 1, (_lrc))    
  121. #endif /* INIT_LRC_IS_LSN */
  122.  
  123. /*
  124.  *  Before a log record (log page) is placed in the log, there
  125.  *  must be some extra space still left in the log.  This
  126.  *  extra space is the log slack.
  127.  */
  128. #define LOG_SLACK (MAX_LOGREC_LEN * 2)
  129.  
  130. #endif /* _LOG_H_ */
  131.